﻿using System;
using System.Collections.Generic;
using System.Security.Principal;
using ActivateYourGlutes.Services.Model;

namespace ActivateYourGlutes.Services
{
    public interface IAccountProvider : IProviderBase
    {
        /// <summary>
        /// Retrieves the current account based on a security principal object 
        /// </summary>
        Account CurrentAccount(IPrincipal user);
        /// <summary>
        /// Creates an account
        /// </summary>
        void Create(string name, string password, string email, DateTime time, UnitOfLength length, UnitOfWeight weight, string dateFormat);
        /// <summary>
        /// Determines if any data has been logged by this user beyond account creation
        /// </summary>
        bool IsDataLoggedForUser(IPrincipal principal);
        /// <summary>
        /// Returns the recent activity the user has made against their account
        /// </summary>
        IEnumerable<Activity> RecentActivity(IPrincipal user);
        /// <summary>
        /// Updates the details of an account
        /// </summary>
        void UpdateAccount(Account forAccount, string email, DateTime exact, UnitOfLength unitOfLength, UnitOfWeight unitOfWeight, IEnumerable<MeasurementType> keyIndicators);
        /// <summary>
        /// Validates the details supplied for logon
        /// </summary>
        void ValidateLogOn(string userName, string password);
        /// <summary>
        /// Validates the details supplied for registration
        /// </summary>
        void ValidateRegistration(string userName, string email, string password, string confirmPassword, bool acceptTerms, DateTime? dob);
        /// <summary>
        /// Validates the details supplied for changing a password
        /// </summary>
        void ValidateChangePassword(string currentPassword, string newPassword, string confirmPassword);
        /// <summary>
        /// Returns the email address for an account from the membership provider
        /// </summary>
        string EmailForAccount(Account account);
        /// <summary>
        /// Returns the minimum password length
        /// </summary>
        int MinPasswordLength { get; }
        /// <summary>
        /// Change the password for the given user
        /// </summary>
        bool ChangePassword(string accountName, string newPassword, string currentPassword, string confirmPassword);
        /// <summary>
        /// Returns all the accounts registered in the system after first checking that the accessing account is an
        /// administrator
        /// </summary>
        IEnumerable<Account> All(Account accessingAccount);
        /// <summary>
        /// Gets the total number of accounts in the system
        /// </summary>
        int TotalAccounts(Account accessingAccount);
        /// <summary>
        /// Returns a subset of all the accounts (used by paging views for example)
        /// </summary>
        IEnumerable<Account> Accounts(Account accessingAccount, int offset, int pageSize);
        /// <summary>
        /// Gets an account with the given ID after checking that the requesting account has rights
        /// to recieve it.
        /// </summary>
        /// <param name="requestingAccount"></param>
        /// <param name="requestedAccountId"></param>
        /// <returns></returns>
        Account GetAccount(Account requestingAccount, int requestedAccountId);
        /// <summary>
        /// Minimal account update used by an adminstrator
        /// </summary>
        void AdminUpdateAccount(Account updatingAccount, int accountId, bool isAdministrator);
        /// <summary>
        /// Delete an account given its account ID
        /// </summary>
        void Delete(Account deletingAccount, int accountId);
    }
}